<%@page import="com.lynn.salary.util.ToolMethod"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String ai = ToolMethod.getCharAndNumr(5);
%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<div class="pageContent">
	<form method="post" action="<%=basePath %>accessory!edit.do?flag=update" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<input type="hidden" name="accessory.id" value="<s:property value='accessory.id'/>"> 
		<div>
			
			<div style="padding-left: 20px;padding-top: 10px;">
				<div>
					<span>附件名:</span>
					<span style="padding-left: 20px;">
						<input type="text" size="54" maxlength="50" name="accessory.name" value="<s:property value='accessory.name'/>"/>
					</span>
				</div>
				<div style="padding-top: 10px;">
					<div style="float: left;">描述:</div>
					<div style="float: left; padding-left: 35px;">
						<textarea maxlength="500" rows="8" cols="44"  name="accessory.description"><s:property value='accessory.description'/></textarea>
					</div>
				</div>
			</div>
			
			
			<div class="divider"></div>
			
			<div style="height: 195px;">
				<div style="float:left;padding-left: 20px;">附件列表</div>
				<div id="auto-<%=ai %>" style="float: left; padding-left: 15px;width: 280px;">
					正在加载数据...
				</div>
			</div>
			<div style="margin-left: 295px;padding-bottom: 10px;">
				<%-- <a target="blank" href="<%=basePath %>accessory!addFile.do?flag=showAddFile&accessory.id=<s:property value='accessory.id'/>">添加</a>
				 --%>
				<a height="380" width="410" resizable=false maxable=false mask=true href="<%=basePath %>accessory!addFile.do?flag=showAddFile&accessory.id=<s:property value='accessory.id'/>" title="添加" target="dialog" rel="addFILE">添加</a>
				
				<a href="javascript:;" id="refresh-<%=ai %>">刷新</a>
			</div>
			
			
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
		
	</form>
</div>

<script>

var tmp = function() {
	return ""+Math.random();
}

var ref_ = function() {
	$.ajax({
		  url: "<%=basePath%>accessory!showFile.do?accessory.id=<s:property value="accessory.id"/>&i="+tmp()
		}).done(function ( data ) {
			$("#auto-<%=ai %>").html(data);
		});
}

var del_ref = function (fid,aid) {
	$.ajax({
		  url: "<%=basePath%>accessory!rmFile.do?accessory.id="+aid+"&systemFile.id="+fid+"&i="+tmp()
		}).done(function ( data ) {
			$("#auto-<%=ai %>").html(data);
		});
}


//fid 文件id   aid 附件id
var del_af = function (fid,aid) {
	var result = confirm("确定移除文件?");
	if(result) {
		del_ref(fid,aid);
	}
}

$("#refresh-<%=ai %>").click(ref_);
ref_();
</script>

